<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>华猫商城</title>
		<style></style>
		<link href="../css/jquery.validator.css" rel="stylesheet">
		<link href="../css/common.css" rel="stylesheet">

		<link href="../plugin/userLib/css/user.css" rel="stylesheet">
		<!--<link href="../plugin/userLib/css/userinfo.css" rel="stylesheet">
		<link href="../plugin/userLib/css/my_user.css" rel="stylesheet">-->
		<link href="../css/base.css" rel="stylesheet">
		<link href="../plugin/userLib/css/shop.css" rel="stylesheet">
		<link href="../plugin/userLib/css/shop_a.css" rel="stylesheet">

		<link href="../plugin/webuploader/webuploader.css" rel="stylesheet">
		<link href="../plugin/webuploader/batchupload.css" rel="stylesheet">
		<link href="../plugin/kindeditor/themes/default/default.css" rel="stylesheet">
		<style>
			.n-default .n-left,
			.n-default .n-right {
				margin-top: 9px!important;
			}
			
			#goodsImgPicker1 {
				top: 32px;
				left: 20px;
				margin-right:152px;
			}
			
			.ZZHT-batchupload .placeholder .webuploader-pick {
				background: #ed5d29;
				height: 35px;
				line-height: 35px;
				font-size: 16px;
			}
			
			.ZZHT-batchupload .statusBar .btns .uploadBtn {
				background: #ed5d29!important;
				height: 35px!important;
				color: #fff!important;
				line-height: 35px;
				-moz-box-sizing: border-box;
				-webkit-box-sizing: border-box;
				box-sizing: border-box;
			}
			
			.ZZHT-batchupload .statusBar .btns .webuploader-pick {
				height: 35px;
				line-height: 35px;
				width: 65px;
				color: #ed5d29!important;
			}
			
			.ZZHT-batchupload .statusBar .btns .uploadBtn:hover {
				background: #ed5d29;
			}
			
			.ZZHT-batchupload .statusBar .btns .webuploader-pick,
			.ZZHT-batchupload .statusBar .btns .uploadBtn,
			.ZZHT-batchupload .statusBar .btns .uploadBtn.state-uploading,
			.ZZHT-batchupload .statusBar .btns .uploadBtn.state-paused {
				background: #ffffff;
				border: 1px solid #ed5d29;
				color: #565656;
				display: inline-block;
				border-radius: 2px;
				margin-left: 10px;
				cursor: pointer;
				font-size: 14px;
				float: left;
			}
			
			.ZZHT-batchupload .statusBar {
				border-top: 1px solid #e6e6e6;
			}
			
			label {
				margin-right: 10px;
			}
			
			#specsAttrBox .webuploader-container {
				width: 100px;
				height: 30px;
				line-height: 30px;
				overflow: hidden;
				margin-right: 10px;
			}
			
			.webuploader-pick {
				background: #ed5d29;
				font-size: 14px;
			}
			
			/*.n-default .n-right {
				margin-top: 9px!important;
			}*/
			
			.HImg_box {
				width: 100%;
				overflow: hidden;
				border-bottom: 1px solid #000;
			}
			
			.HImg {
				width: 100px;
				height: 100px;
				float: left;
				overflow: hidden;
				margin: 5px;
				position: relative;
			}
			
			.HImg img {
				width: 100%;
				height: 100%;
			}
			
			.remove_img {
				position: absolute;
				top: 0;
				right: 0;
				cursor: pointer;
				display: block;
				background-color: #000;
				color: #fff;
				padding: 5px 10px;
			}
			
			.ZZHT-batchupload .placeholder {
				min-height: 200px;
			}
			select{
				padding-right: 20px !important;
			}
			.ZZHT-menu li.active a{
				color:#D0260C;
			}
		</style>
	</head>

	<body>
		<div id="header"></div>
		<div id="headerBox"></div>
		<!--<div id="nav_menu"></div>-->
		<div class="ZZHT-wrap">
			<div class="ZZHT-header" style="border-bottom: 1px solid #ffffff;">
				<div class="ZZHT-shop-nav">
					<div class="ZZHT-nav-box">
						<a href="#">
							<li class="liselect ZZHT-lfloat ZZHT-nav-boxa">商城商家</li>
						</a>
						<div class="ZZHT-clear"></div>
					</div>
				</div>
				<div class="ZZHT-clear"></div>
			</div>
			<div class="ZZHT-main">
				<div id="onLine_left"></div>
				<div class="ZZHT-content" id="app">

					<div class="ZZHT-user-head clearfix"><span class="left fl aORe">新增商品</span><span class="rights fr">当前位置：商品管理-- <span class="aORe">新增商品</span></span></div>
					<div id="tab" class="ZZHT-tab-box">
						<ul class="ZZHT-tab-nav clearfix">
							<li><span>商品信息</span></li>
							<li><span>规格属性</span></li>
							<li><span>商品相册</span></li>
						</ul>
						<div class="ZZHT-tab-content" style="width:100%;padding: 30px 0;border:0px;">
							<form id="editform" autocomplete="off">
								<div class="ZZHT-tab-item" style="position: relative;">
									<input type="hidden" id="goodsId" class="j-ipt" value="0">
									<table class="ZZHT-form ZZHT-forms">
										<tbody>
											<tr>
												<th width="150">商品名称：</th>
												<td width="300">
													<input type="text" class="j-ipt" id="goodsName" v-model="goods.goodsName" value="" maxlength="100" data-rule="商品名称:required;">
												</td>
											</tr>
											<tr>
												<th width="150">上传商品图片：</th>
												<td colspan="6">
													<div id="goodsImgBox" style="float:left">
														<img id="preview" src="http://zzhtwl.oss-cn-qingdao.aliyuncs.com/sysconfigs/e495472e3d5a3fa965e61118c41c5fff.png" width="140" height="100">
													</div>
													<div id="goodsImgPicker1" class="webuploader-container">
														<div class="webuploader-pick">上传</div>
														<div id="rt_rt_1cdbk34ih1tbn1kben8lg4ar1e1" style="position: absolute; top: 0px; left: 0px; width: 120px; height: 44px; overflow: hidden; bottom: auto; right: auto;"><input type="file" name="file" class="webuploader-element-invisible" multiple="multiple" accept="image/*"><label style="opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255);"></label></div>
													</div><span id="uploadMsg"></span>
													<input type="hidden" id="goodsImg" class="j-ipt" data-target="#msg_goodsImg" value="" data-rule="商品图片: required;">
													<span class="msg-box" id="msg_goodsImg" style="margin-top:38px!important;"></span>
													<div class="ZZHT-clear"></div>
												</td>
											</tr>
											<tr>
												<th>商品编号：</th>
												<td><input type="text" class="j-ipt" id="goodsSn" v-model="goods.goodsSn" value="" maxlength="20" data-rule="商品编号:required;"></td>
											</tr>
											<tr>
												<th width="150">商品货号：</th>
												<td width="300">
													<input type="text" class="j-ipt" id="productNo" value="" v-model="goods.productNo" maxlength="20" data-rule="商品货号:required;">
												</td>
											</tr>
											<tr>
												<th>市场价格：</th>
												<td><input type="text" class="j-ipt" id="marketPrice" value="0.00" v-model="goods.marketPrice" maxlength="10" data-rule="商场价格:required;checkmoney" data-rule-checkmoney="[/^(([1-9]\d*(\.\d*)?)|(0\.\d[1-9]))$/,'商场价格不能小于0']"></td>
											</tr>
											<tr>
												<th>店铺价格：</th>
												<td><input type="text" class="j-ipt" id="shopPrice" value="0.00" maxlength="10" v-model="goods.shopPrice" data-rule="店铺价格:required;checkMoney" data-rule-checkmoney="[/^(([1-9]\d*(\.\d*)?)|(0\.\d[1-9]))$/,'店铺价格不能小于0']"></td>
											</tr>
											<tr>
												<th>积分赠送比例：</th>
												<td><input type="text" class="j-ipt" id="scoreRatio" v-model="goods.scoreRatio" placeholder="请输入0-500之间的正整数" data-target="#scoreRatio" data-rule="积分赠送比例:required;checkScoreRatio" data-rule-checkscoreratio="[/^(?:[0-9]|[1-9]\d?|[1234]\d{2}|500)$/,'积分赠送比例必须在0-500之间']"><span class="ZZHT-f999" style="margin-left: -30px;">&nbsp;%&nbsp;</span><span id="scoreRatioa" class="fl"></span></td>
											</tr>
											<tr>
												<th>商品库存：</th>
												<td><input type="text" class="j-ipt" id="goodsStock" value="0" v-model="goods.goodsStock" maxlength="10" data-rule="商品库存:required;integer[+]"></td>
											</tr>
											<tr>
												<th>预警库存：</th>
												<td><input type="text" class="j-ipt" id="warnStock" value="0" maxlength="10" v-model="goods.warnStock" data-rule="预警库存:required;integer[+]"></td>
											</tr>
											<tr>
												<th>商品单位：</th>
												<td colspan="2"><input type="text" class="j-ipt" id="goodsUnit" v-model="goods.goodsUnit" value="" maxlength="10" data-rule="商品单位:required;"></td>
											</tr>
											<tr>
												<th>SEO关键字：</th>
												<td><input type="text" class="j-ipt" id="goodsSeoKeywords" v-model="goods.goodsSeoKeywords" maxlength="100" value=""></td>
											</tr>
											<tr>
												<th>商品促销信息：</th>
												<td colspan="2"><textarea class="j-ipt" id="goodsTips" maxlength="100" v-model="goods.goodsTips" style="width:400px;height:50px;"></textarea></td>
											</tr>
											<tr>
												<th>商品状态：</th>
												<td colspan="2">
													<div>
														<label><input type="radio" name="isSale" id="isSale-1" class="j-ipt" value="1" v-model="goods.isSale"><label for="isSale-1" class="mt-1"></label>上架</label>
														<label><input type="radio" name="isSale" id="isSale-0" class="j-ipt" value="0" v-model="goods.isSale"><label for="isSale-0" class="mt-1"></label>下架</label>
													</div>
												</td>
											</tr>
											<tr>
												<th>商品属性：</th>
												<td colspan="2">
													<div class="">
														<label>
          <input id="isRecom" v-model="goods.isRecom" name="isRecom" class="j-ipt " :value="1||0" type="checkbox"><label class="mt-1" for="isRecom"></label>推荐
														</label>
														<label>
          <input id="isBest" v-model="goods.isBest" name="isBest" class="j-ipt " value="" type="checkbox"><label class="mt-1" for="isBest"></label>精品
														</label>
														<label>
          <input id="isNew" v-model="goods.isNew" name="isNew" class="j-ipt " value="" type="checkbox"><label class="mt-1" for="isNew"></label>新品
														</label>
														<label>
          <input id="isHot" v-model="goods.isHot" name="isHot" class="j-ipt " value="" type="checkbox"><label class="mt-1" for="isHot"></label>热销
														</label>
													</div>
												</td>

											</tr>
											<tr>
												<th>商城分类：</th>
												<td colspan="2">
													<select id="cat_1" class="ipt j-goodsCats" v-model="goodsf1_now">
														<option value="">-请选择-</option>
														<option v-for="v in goodsf1" :value="v.catId">{{v.catName}}</option>
													</select>
													<select id="cat_2" v-if="goodsf2.length>0" class="ipt j-goodsCats" v-model="goodsf2_now">
														<option value="">-请选择-</option>
														<option v-for="v in goodsf2" :value="v.catId">{{v.catName}}</option>
													</select>
													<select id="cat_3" v-if="goodsf3.length>0" class="ipt j-goodsCats" v-model="goodsf3_now">
														<option value="">-请选择-</option>
														<option v-for="v in goodsf3" :value="v.catId">{{v.catName}}</option>
													</select>
												</td>
											</tr>
											<tr>
												<th>本店分类：</th>
												<td colspan="2">
													<select id="shopCatId1" class="j-ipt" v-model="goods.shopCatId1">
														<option value="">-请选择-</option>
														<option v-for="v in shopf1" :value="v.catId">{{v.catName}}</option>
													</select>
													<select id="shopCatId2" class="j-ipt" v-if="shopf2.length>0" v-model="goods.shopCatId2">
														<option value="">请选择</option>
														<option v-for="v in shopf2" v-if="v.parentId==goods.shopCatId1" :value="v.catId">{{v.catName}}</option>
													</select>
												</td>
											</tr>
											<tr>
												<th>品牌：</th>
												<td colspan="2">
													<select id="brandId" class="j-ipt" v-model="goods.brandId">
														<option value="">-请选择-</option>
														<option v-for="v in brand" :value="v.brandId">{{v.brandName}}</option>
													</select>
												</td>
											</tr>
											<tr>
												<th>商品描述：</th>
												<td colspan="2">
													<div id="editor"></div>
												</td>
											</tr>
											<tr>
												<td colspan="3" align="center" style="text-align:center">
													<div class="footer_0">
														<div class="fredBtn detail_save" @click="detail_save">确认</div>
														<button class="emptyBtn" type="reset">重置</button>
													</div>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
								
								<div class="ZZHT-tab-item" style="position: relative; display: block;">
									<div id="specsAttrBox">
										<div class="spec-head">商品规格</div>
										<!--<div class="spec-body" v-for="(v,i) in spec.specItemss">
											<div class="spec-line"></div>
											<div :id='"specCat_"+v.catId'>{{v.catName}}</div>
											<div class="clearfix">
												<div class="spec-item" v-for="(item,ind) in v.itemDesc">
													<input type="checkbox" :class='"j-speccat j-speccat_"+ind+" j-spec_"+v.catId+"_0"' :cat="v.catId" :num="i" v-model="item.isShow" @click="changeSpec()">
													<input type="text" class="spec-ipt" :id='"specName_"+v.catId+"_"+ind' maxlength="50" v-model="item.val" @change="changeSpec()"><span class="item-del" @click='delSpec(i,ind,item.itemId)'></span>
												</div>
												<input type="button" style="margin-top:8px;margin-right:10px;margin-left:10px;" value="新增" :id='"specAddBtn_"+v.catId' @click="addSpec(v.catId,v.catName,i)">
											</div>
										</div>-->
										<div class="spec-body" v-for="(v,i) in spec.specItemss">
											<div class="spec-line"></div>
											<div :id='"specCat_"+v.catId'>{{v.catName}}</div>
											<div class="clearfix">
												<div class="spec-item" v-for="(item,ind) in v.itemDesc">
													<input type="checkbox" :class='"j-speccat j-speccat_"+ind+" j-spec_"+v.catId+"_0"' :cat="v.catId" :num="i" v-model="item.dataFlag" @click="editSpec(i,ind,0)">
													<input type="text" class="spec-ipt" :id='"specName_"+v.catId+"_"+ind' maxlength="50" v-model="item.val" @change="editSpec(i,ind,1)"><span class="item-del" @click='delSpec(i,ind,item.itemId)'></span>
												</div>
												<input type="button" style="margin-top:8px;margin-right:10px;margin-left:10px;" value="新增" :id='"specAddBtn_"+v.catId' @click="addSpec(v.catId,v.catName,i)">
											</div>
										</div>
										<div id="specSaleHead" class="spec-head">销售规格</div>
										<table class="specs-sale-table">
											<thead id="spec-sale-hed">
												<tr>
													<th>推荐<br>规格</th>
													<th class="j-saleTd" v-for="(v,i) in spec.tabArr">{{v[0].catName}}</th>
													<th id="thCol">货号</th>
													<th>市场价<br><input type="text" class="spec-sale-ipt marketPriceh" @input="batchChange('marketPrice')"></th>
													<th>本店价<br><input type="text" class="spec-sale-ipt specPriceh" @input="batchChange('specPrice')"></th>
													<th>库存<br><input type="text" class="spec-sale-ipt specStockh" @input="batchChange('specStock')"></th>
													<th>预警库存<br><input type="text" class="spec-sale-ipt warnStockh" @input="batchChange('warnStock')"></th>
													<th>销量</th>
												</tr>
											</thead>
											<tbody id="spec-sale-tby">
												<tr class="j-saleTd tab_tr" v-for="(v,i) in spec.listArr">
													<td><input type="radio" class="j-ipt" name="default"></td>
													<td v-for="(item,ind) in v" :data-id="item.itemId">{{item.val}}</td>
													<td class="productNo_td"><input type="text" class="spec-sale-goodsNo j-ipt" :value='"152810785487783-"+i'></td>
													<td class="marketPrice_td"><input type="text" class="spec-sale-ipt j-ipt marketPrice"></td>
													<td class="specPrice_td"><input type="text" class="spec-sale-ipt j-ipt specPrice"></td>
													<td class="specStock_td"><input type="text" class="spec-sale-ipt j-ipt specStock"></td>
													<td class="warnStock_td"><input type="text" class="spec-sale-ipt j-ipt warnStock"></td>
													<td class="saleNum_td"><input type="text" class="spec-sale-ipt j-ipt" value="0" disabled></td>
												</tr>
											</tbody>
										</table>
										<div class="spec-head">商品属性</div>
										<div class="spec-body">
											<table class="attr-table">
												<tbody>
													<tr v-for="v in spec.goodsAtrrbutess">
														<th width="120" nowrap="">{{v.attrName}}</th>
														<td v-if="v.attrType==0"><input type="text" name="" :id='"attr_"+v.attrId' class="spec-sale-text j-ipt"></td>
														<td v-else-if="v.attrType==1"><label><input type="checkbox" class="j-ipt" name="" :value="v.attrVal">{{v.attrVal}}</label></td>
														<td v-else-if="v.attrType==2">
															<select name="" id="">
																<option value="">选择</option>
															</select>
														</td>
													</tr>
												</tbody>
											</table>
										</div>
									</div>
									<div style="margin:0px auto;text-align:center;">
										<div class="footer_0">
											<div class="fredBtn" @click="specSave()">确认</div>&nbsp;&nbsp;
											<button class="emptyBtn" type="reset">重置</button>
										</div>
									</div>
								</div>
								<div class="ZZHT-tab-item" style="position: relative;padding:0px 20px;">
									<div class="HImg_box">
										<div>已经上传的图片</div>
										<ul>
											<li class="HImg" v-for="(v,i) in goods.gallery">
												<img :src="v" alt="" />
												<span class="remove_img" @click="remove_img(i)">删除</span>
											</li>
										</ul>
									</div>
									<div id="batchUpload" class="ZZHT-batchupload">
										<div class="queueList filled">
											<div id="dndArea" class="placeholder ">
												<div id="filePicker" class="webuploader-container">
													<div class="webuploader-pick">点击选择图片</div>
													<div id="rt_rt_1cfcd1bk523om0c1vsj1jm075vc" style="position: absolute; top: 0px; left: 390px; width: 120px; height: 44px; overflow: hidden; bottom: auto; right: auto;"><input type="file" name="file" class="webuploader-element-invisible" multiple="multiple" accept="image/*"><label style="opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255);"></label></div>
												</div>
												<p>或将照片拖到这里，单次最多可选50张，每张最大不超过5M</p>
											</div>
											<ul class="filelist">
												
											</ul>
										</div>
										<div class="statusBar" style="display: none;">
											<div class="progress" style="display: none;">
												<span class="text">0%</span>
												<span class="percentage" style="width: 0%;"></span>
											</div>
											<div class="info"></div>
											<div class="btns">
												<div id="filePicker2"></div>
												<div class="uploadBtn">开始上传</div>
											</div>
										</div>
									</div>
									<div style='margin:0px auto;text-align:center;border-top:1px solid #e6e6e6;'>
										<div class="footer_0">
											<!--<div class='fredBtn' onclick='javascript:save()'>确认</div>&nbsp;&nbsp;-->
											<div class='fredBtn save_gallery' @click="detail_save()">确认</div>&nbsp;&nbsp;
											<!--<button class='emptyBtn' type="reset">重置</button>-->
										</div>
									</div>
								</div>
							</form>
						</div>
					</div>

				</div>

			</div>
			<div style="clear:both;"></div>
			<br>
		</div>
		<div id="ck3"></div>
		<script src="../js/jquery.min.js"></script>
		<script src="../js/jquery.validator.js"></script>
		<script src="../js/zh-CN.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../plugin/layer/laydate/laydate.js"></script>
		<script src="../plugin/layer/layer.js"></script>
		<script src="../plugin/webuploader/webuploader.js"></script>
		<script src="../plugin/webuploader/batchupload.js"></script>
		<script type="text/javascript" src="../plugin/wangEditor-3.1.1/release/wangEditor.min.js"></script>

		<script type="text/javascript" src="../js/ljf_base.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/common_view.js"></script>
		<script src="../plugin/userLib/js/goods.js"></script>
		<script>
			var initBatchUpload = false,
				editor1 = null,
				loading = null,
				specNum = 0,
				goodsId = '',
				shopId = '',
				oldPath = '',//上一次的商城分类
				specType = 'add', //新增 或修改商品规格
				src = 'add'; //新增add 修改edit 商品详情
			var vm = new Vue({
				el: '#app',
				data: {
					goods: {
						goodsSn: '', //选填	商品编号
						goodsName: '', //选填	商品名称
						goodsImg: '', //选填	上传商品图片
						productNo: '', //选填	商品货号
						marketPrice: '', //选填	市场价
						shopPrice: '', //选填	门店价
						scoreRatio: '100', //选填	积分赠送比例
						goodsStock: '', //选填	商品库存
						warnStock: '', //选填	预警库存
						goodsUnit: '', //选填	商品单位
						goodsSeoKeywords: '', //选填	SEO关键字
						goodsTips: '', //选填	促销信息
						isSale: 1, //选填	商品状态
						isHot: 1, //选填	是否热销
						isNew: 1, //选填	是否新品
						isRecom: 1, //选填	是否推荐
						isBest: 1, //选填	是否精品
						goodsCatIdPath: '', //选填	商品分类ID
						goodsCatId: '',
						shopCatId1: '', //选填	门店1级分类
						shopCatId2: '', //选填	门店2级分类
						brandId: 0, //选填	品牌ID
						goodsDesc: '', //选填	商品描述
						gallery: [], //选填	商品相册
						shopId: '', //选填	商铺id
					},
					goodsf1: [],
					goodsf1_now: '',
					goodsf2: [],
					goodsf2_now: '',
					goodsf3: [],
					goodsf3_now: '',
					shopf1: [],
					shopf2: [],
					brand: [],
					spec: {
						goodsId: goodsId,
						specItemss: [], //规格
						tabArr: [], //表头
						listArr: [], //重新组合后的数组
						goodsSpecss: [{
							shopId: shopId,
							productNo: '111', //选填	商品货号
							specIds: '4', //选填	规格ID
							marketPrice: '11', //选填	市场价
							specPrice: '11', //	选填	商品价
							specStock: '11', //	选填	库存
							warnStock: '11', //	选填	预警值
							saleNum: '11', //	选填	销量
							isDefault: '1', //	选填	默认规格
						}],
						goodsAttributess: [{
							shopId: shopId,
							attrId: '111', //选填	属性id
							attrVal: '222',
						}],
					},
				},
				methods: {
					detail_save: function() { //保存商品详情
						var that = this;
						loading = ZZHT.msg('正在提交数据，请稍后...', {
							icon: 16,
							time: 6000
						});
						var obj = that.goods;

						obj.isBest ? obj.isBest = 1 : obj.isBest = 0;
						obj.isHot ? obj.isHot = 1 : obj.isHot = 0;
						obj.isNew ? obj.isNew = 1 : obj.isNew = 0;
						obj.isRecom ? obj.isRecom = 1 : obj.isRecom = 0;

						obj.goodsImg = $('#goodsImg').val();
						obj.goodsDesc = $('#goodsDesc').val();

						var msg = '';
						if(!that.goodsf3_now && !that.goodsf2_now && !that.goodsf1_now) {
							msg = '请选择商城分类';
						} else {
							obj.goodsCatId = that.goodsf3_now || that.goodsf2_now || that.goodsf1_now

							var path = "";
							path += that.goodsf1_now;
							if(that.goodsf2_now) {
								path += '_' + that.goodsf2_now;
							};
							if(that.goodsf3_now) {
								path += '_' + that.goodsf3_now;
							};
							obj.goodsCatIdPath = path;
						}
						
						if(!obj.brandId) {
							obj.brandId = 0;
						}

						obj.goodsDesc = editor1.txt.html(); //富文本编辑器
						
						if(src=='add'||that.goods.gallery=='[]'){
							that.goods.gallery = [];
							if($('.j-gallery-img').length > 0) { //相册
								$.each($('.j-gallery-img'), function(i, v) {
									that.goods.gallery.push($(this).attr('v'));
								})
							};
						}
						
						obj.gallery = JSON.stringify(that.goods.gallery);

						$('#editform').isValid(function(v) {
							if(v) {
								if(msg == '') {
									console.log(obj);
									if(src == "add") {
										add(obj);
									} else {
										edit(obj);
									}
								} else {
									layer.close(loading);
									layer.msg(msg);
								}
							} else {
								layer.close(loading);
							}
						});
					},
					addSpec: function(catId,catName,i) { //新增规格
						var obj = {
							catId:catId,
							catName: catName,
							val: '',
							itemId:'',
							dataFlag:false,
						};
						var arr = [];
						arr.push(obj);
						var that = this;
						getItemId(arr,function(arr){
							var obj = arr[0];
							that.spec.specItemss[i].itemDesc.push(obj);
						})
					},
					delSpec: function(i, ind ,itemId) { //删除商品规格
						
						$.ajax({ //获取商城第二级分类
							type: "get",
							url: SURL + "goods/deleteGoodsCat",
							data:{
								itemId:itemId
							},
							async: false,
							success: function(data) {
								console.log(data);
							}
						});
						
						this.spec.specItemss[i].itemDesc.splice(ind, 1);
						changeSpec();
					},
					editSpec:function(i,ind,type){//编辑规格
						var that = this;
						var item = this.spec.specItemss[i].itemDesc[ind];
						var flag = item.dataFlag?1:-1;
//						if(type==0){
//							var flag = item.dataFlag=='1'?'-1':'1';
//							item.dataFlag = flag;
//						}
						var obj = {
							catId:that.spec.specItemss[i].catId,
							catName: that.spec.specItemss[i].catName,
							val: item.val,
							itemId:item.itemId,
							dataFlag:flag,
						}
						console.log(obj);
						var arr = [];
						arr.push(obj);
						getItemId(arr,function(arr){
							console.log(arr);
							changeSpec();
						});
					},
					batchChange: function(type) {
						batchChange(type);
					},
					remove_img: function(i) {
						console.log(this.goods.gallery);
						this.goods.gallery.splice(i, 1);
					},
					specSave: function() { //保存规格
						specSave();
					},
				},
				watch: {
					goodsf1_now: function(res) { //切换第一类
						var that = this;
						that.goodsf2 = [];
						that.goodsf2_now = '';
						that.goodsf3 = [];
						that.goodsf3_now = '';
						getBrand(res);
						if(res) {
							$.ajax({ //获取商城第二级分类
								type: "get",
								url: SURL + "goodsCats/selectByGoodsInfo/" + res,
								async: false,
								success: function(data) {
									that.goodsf2 = data.entity;
								}
							});
						}
					},
					goodsf2_now: function(res) { //切换第二类
						var that = this;
						that.goodsf3 = [];
						that.goodsf3_now = '';
						if(res) {
							$.each(that.goodsf2, function(i, v) {
								if(v.catId == res) {
									that.goodsf3 = that.goodsf2[i].childs;
								}
							})
						}
					}
				}
			});

			$(function() {
				$.ajax({ //获取商城第一级分类
					type: "get",
					url: SURL + "goodsCats/selectFirstCat",
					success: function(data) {
						vm.goodsf1 = data.entity;
						//获取店铺分类列表
						$.get(SURL + 'sktShops/findByUserId', {
							userId: localStorage.userId
						}, function(data, textStatus) {
							shopId = data.entity[0].shopId;

							vm.goods.shopId = shopId;

							getList();
						});
					}
				});

				initEdit();

			});
		</script>
	</body>

</html>